# Maintainer : Jason Plum <jplum@archlinuxarm.org>

# Copyright (C) 2012  Alejandro Mery <amery@geeks.cl>, GPLv2+

buildarch=4

pkgname=sunxi-tools
pkgver=20140120
pkgrel=1
pkgdesc="Tools for Allwinner SoC family: fex, fel, pheonix_info"
arch=('arm' 'armv7h')
url="https://github.com/linux-sunxi/sunxi-tools"
license=('GPLv2+')
depends=('libusb')
makedepends=('git')
source=("git://github.com/linux-sunxi/sunxi-tools.git")
md5sums=('SKIP')

build() {
  cd ${srcdir}/${pkgname}
  
  make
}

package() { 
  cd $srcdir/${pkgname}

  # install README & LICENSE
  install -Dm 644 README $pkgdir/usr/share/doc/$pkgname/README
  install -Dm 644 COPYING $pkgdir/usr/share/licenses/$pkgname/COPYING

  # create directory structure
  mkdir -p $pkgdir/usr/bin

  # copy binaries
  cp fexc $pkgdir/usr/bin
  cp bootinfo $pkgdir/usr/bin
  cp fel $pkgdir/usr/bin
  cp usb-boot $pkgdir/usr/bin
  cp fel-gpio $pkgdir/usr/bin
  cp pio $pkgdir/usr/bin
  cp nand-part $pkgdir/usr/bin

  # make symlinks for bin2fex/fex2bin
  cd $pkgdir/usr/bin
  ln -s fexc fex2bin
  ln -s fexc bin2fex
}
